package com.wolfheader.wolfgame.entity.admin;

import java.math.BigDecimal;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.Digits;
import javax.validation.constraints.Min;
import javax.validation.constraints.Pattern;

import org.hibernate.validator.constraints.Length;

import com.wolfheader.wolfgame.entity.BaseEntity;

/**
 * 微商代理
 * 
 * @author Administrator
 *
 */
@Entity
@Table(name = "t_person")
public class PersonEntity extends BaseEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = -9009108846460410539L;

	/**
	 * 微信名称
	 */
	private String wxName;

	/**
	 * 联系方式
	 */
	private String phone;

	/**
	 * 城市
	 */
	private String city;

	/**
	 * 送货地址
	 */
	private String address;

	/**
	 * 代理产品
	 */
	private ProductEntity product;

	/**
	 * 身份ID
	 */
	private String idNo;

	/**
	 * 添加描述
	 */
	private String remark;

	/**
	 * 补货次数
	 */
	private Integer consumeCount;

	/**
	 * 消费金额
	 */
	private BigDecimal consume;

	/**
	 * 待发货的计量 - 盒 需转换成箱
	 */
	private Integer waitHeCount;

	/**
	 * 已发货的计量 - 盒 需转换成箱
	 */
	private Integer sendHeCount;

	@Length(min = 4, max = 20)
	@Column(nullable = false)
	public String getWxName() {
		return wxName;
	}

	public void setWxName(String wxName) {
		this.wxName = wxName;
	}

	@Pattern(regexp = "^1[3,5,8]\\d{9}$")
	@Column(nullable = false, length = 20)
	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	@Length(min = 4, max = 100)
	@Column(nullable = false)
	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	@Length(min = 4, max = 100)
	@Column(nullable = false)
	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}
	
	@ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(nullable = false, updatable = false)
	public ProductEntity getProduct() {
		return product;
	}

	public void setProduct(ProductEntity product) {
		this.product = product;
	}

	@Pattern(regexp = "^([1-9]\\d{7}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3})|([1-9]\\d{5}[1-9]\\d{3}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])((\\d{4})|\\d{3}(x|X)))$")
	@Column(nullable = false, length = 20)
	public String getIdNo() {
		return idNo;
	}

	public void setIdNo(String idNo) {
		this.idNo = idNo;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}
	
	@Column(nullable = false)
	public Integer getConsumeCount() {
		return consumeCount;
	}

	public void setConsumeCount(Integer consumeCount) {
		this.consumeCount = consumeCount;
	}

	@Min(0)
    @Digits(integer = 19, fraction = 2)
    @Column(nullable = false)
	public BigDecimal getConsume() {
		return consume;
	}

	public void setConsume(BigDecimal consume) {
		this.consume = consume;
	}
	
	@Column(nullable = false)
	public Integer getWaitHeCount() {
		return waitHeCount;
	}

	public void setWaitHeCount(Integer waitHeCount) {
		this.waitHeCount = waitHeCount;
	}
	
	@Min(0)
	@Column(nullable = false)
	public Integer getSendHeCount() {
		return sendHeCount;
	}

	public void setSendHeCount(Integer sendHeCount) {
		this.sendHeCount = sendHeCount;
	}

}
